package ua.org.ass;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
 *
 * @author frick.ua
 */
public class HTTPServlet implements Servlet {

    @Override
    public void init(ServletConfig config) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest req, ServletResponse res)
            throws ServletException, IOException {
        if (req instanceof HttpServletRequest
                && res instanceof HttpServletResponse) {
            HttpServletRequest httpReq = (HttpServletRequest) req;
            HttpServletResponse httpRes = (HttpServletResponse) res;
				String method = httpReq.getMethod();
				httpRes.addHeader("Server", "HutServer v.1.0b");
            if ("POST".equals(method)) {
                post(httpReq, httpRes);
            } else if ("GET".equals(method)) {
                get(httpReq, httpRes);
            } else if ("PUT".equals(method)) {
                put(httpReq, httpRes);
            }
        } else {
            throw new IllegalArgumentException("Unsuported request type.");
        }
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        
    }

    public void post(HttpServletRequest req, HttpServletResponse res) {

    }

    public void get(HttpServletRequest req, HttpServletResponse res) {

    }

    public void put(HttpServletRequest req, HttpServletResponse res) {

    }
}
